<template>
	<view class="container">

		<view class="ItemList">
			<block v-for="(item,index) in list" :key="index">
				<view class="header-title">
					{{item.title}}
				</view>
				<view class="ItemDetialList">
					<block v-if="item.filterList.length > 0">
						<view class="item" v-for="(ItemDetial,itemIndex) in item.filterList" v-for-item="ItemDetail" :key="itemIndex">
							<view class="itemDetial"
								 :data-id="ItemDetial.id" @click="changeItem">
									<image :src="ItemDetial.imgurl" style="height: 200rpx; width: 100%;">
									</image>
								<view class="title">
									{{ItemDetial.title}}
								</view>
								<image v-if="ItemDetial.id==navId" src="../../static/images/youxiajiaoxuanzhong.png" class="choosed"></image>
							</view>
						</view>
					</block>
					
				</view>
			</block>
		</view>
		<view style="height: 130rpx;width:100%;">
		</view>
		<view class="BtnBottom">
			<button @click="cancel" style="color: bac;">取消</button>
			<button @click="enter" style="color: white;">确认</button>
		</view>
		
	</view>
</template>

<script>
	
	import Http from '../../utils/http';
	const http =new Http()
	export default {
		data() {
			return {
				list: [],
				navId: 1,
			}
		},
		onLoad() {
			this.getAlifilterList()
		},
		mounted() {
			const app = getApp()
			this.baseHttp = app.globalData.baseHttp; // 输出 '我是全局变量'
		},
		methods: {
			getAlifilterList(){
				http.get("v1/alifilter/list").then(res=>{
					 console.log("过滤======>",res);
					 this.list = res.data.data
				})
			},
			// cancel(){
			// 	uni.navigateTo({
			// 		url:'/subpkg/createShop/createShop',
			// 	})
			// },
			enter(){
				 var pages = getCurrentPages()
				 var currentPage = pages[pages.length-2]
				 for(let i=0;i<this.list.length;i++){
					 for(let j=0;j<this.list[i].filterList.length;j++){
						 if(this.list[i].filterList[j].id == this.navId){
							 currentPage.$vm.form.filter = this.list[i].filterList[j].subType
							 console.log(currentPage.$vm.form);
							 uni.navigateBack({delta:1})
						 }
					 }
				 }
				 
				 console.log();
			},
			// 选择行业
			changeItem(e) {
			  let id = e.currentTarget.dataset.id
			  
			  this.navId = id
			},
			getList() {
				http.get('v1/system/trade/list').then(res=>{
					this.filterList = res.data.data;
					console.log(this.filterList);
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.container {
		padding: 0 20rpx;
		background-color: rgb(240, 242, 255);
		min-height: 100vh;
		height: 100%;
		box-sizing: border-box;
		}
		.top {
			font-size: 27rpx;
			color: red;
			font-weight: bold;
		}
.header-title{
	font-size: 36rpx;
	font-weight: bold;
	height: 70rpx;
	line-height: 70rpx;
}

.ItemDetialList {
					width: 100%;
					display: flex;
					margin: 20rpx 0rpx;
					justify-content: space-between;
					flex-wrap: wrap;

					.item {
						height: 200rpx;
						width: 47%;
						box-sizing: border-box;
                          position: relative;
						.itemDetial {
							display: flex;
							flex-direction: column;
							align-items: center;
							background-color: white;
							border-radius: 20rpx;
						   

							.title {
								font-size: 25rpx;
							}
						}
					}
				}
		.ItemList {
			display: flex;
			flex-direction: column;
			.item {
				margin: 10rpx 0rpx;

				.title {
				   height: 60rpx;
				   line-height: 60rpx;
					width: 130rpx;
					background: rgba(0, 0, 0, 0.6);
					position: absolute;
					bottom: 0;
					left: 0;
					color: #fff;
					text-align: center;
					font-size: 30rpx;
					border-radius: 8rpx;
					
				}

				

			}
		}
		.BtnBottom{
			// width: 100vw;
			
			display: flex;
			position: fixed;
			bottom: 0px;
			left:0;
			right: 0;
			justify-content: space-between;
			margin-bottom: 10rpx;
			button{
				width: 45%;
				height: 100rpx;
				border-radius: 20rpx;
				background-color: #00008B;
			}
			button:first-child {
			    background-color: white /* 添加右侧间距 */
			}
		}
.choosed{
	height: 60rpx;
	width: 60rpx;
	position: absolute;
	bottom: 0;
	right: 0;
}
</style>